<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //九九乘法表
        // for (var row = 1; row <= 9; row++) {
        //     var po = "";
        //     for (var col = 1; col <= row; col++) {
        //         po += `${col}*${row}=${row * col}` + (row * col >= 10 ? " " : "  ");
        //     }
        //     console.log(po);

        // }
        // var animate = {
        //     name: 'caca',
        //     price: 40
        // };
        // Object.defineProperty(animate, "ca", {
        //     value: 'call',
        //     configurable: false,//可删除
        //     enumerable: false,//可遍历
        //     writable: false//可写
        // });
        // Object.defineProperties(animate, {
        //     name: {
        //         value: "aa",
        //         configurable: false
        //     }
        // });
        // delete animate.name;
        // console.log(Object.getOwnPropertyDescriptor(animate, "name"));
        // console.log(Object.getOwnPropertyDescriptors(animate));
        // console.log(animate);
        // //防扩展
        // // Object.preventExtensions(animate);
        // //密封
        // // Object.seal(animate);
        // //冻结
        // Object.freeze(animate);
        // animate.color = "黑色";
        // delete animate.price;
        // console.log(animate, '111');
        // console.log(Object.isFrozen(animate));
        // console.log(Object.isExtensible(animate));

        // var cat = {
        //     name: "白猫",
        //     color: "黑白",
        //     food: ["小鱼", "鸡腿"]
        // }
        // cat = JSON.stringify(cat);
        // console.log(cat);
        // console.log(JSON.parse(cat));
        //练习: 将请求地址的查询参数转换为JSON字符串
        // https:// ==> 协议
        // www.baidu.com ==> 域名
        // /s ==> 请求路径
        // ?wd=一组数字描绘丰收里的中国&sa=fyb_n_homepage&rsv_dl=fyb_n_homepage&from=super&cl=3&tn=baidutop10&fr=top1000&rsv_idx=2&hisfilter=1 ==> 请求参数
        var url = 'https://www.baidu.com/s?wd=一组数字描绘丰收里的中国&sa=fyb_n_homepage&rsv_dl=fyb_n_homepage&from=super&cl=3&tn=baidutop10&fr=top1000&rsv_idx=2&hisfilter=1';

        //期望得到的结果
        /*
        '{"wd": "一组数字描绘丰收里的中国", "sa": "fyb_n_homepage", "rsv_dl": "fyb_n_homepage", "from": "super", "cl": 3, "tn": "baidutop10", "fr": "top1000", "rsv_idx": 2, "hisfilter": 1}'
        */
        var cat = url.split("?")[1].split("&");
        var mask = {};
        cat.forEach(function (value) {
            value = value.split("=");
            mask[value[0]] = value[1];
        });
        console.log(JSON.stringify(mask));

        //角色
        var role = {
            name: "吃瓜大白猫",
            age: 5021,
            skills: [
                {
                    name: "噬灵",
                    description: ""
                },
                {
                    name: "封灵",
                    description: ''
                },
                {
                    name:"推演",
                    description:''
                }
            ],
            nature: ["古神", "天道", "魔性", "惟我", "生灵"],
            record: ''
        }
        // console.log(JSON.stringify(role));
        for(var index = 0;index<role.skills.length;index++){
            role.skills[index]["Lv"] = 0;
            
        }
        console.log(role);
        
        var log = (function callThis(){
            return function (data){
                console.log(data);
            }
        })();
        // fn("你好");
        // for(var key in role){
        //     fn(key);
        //     fn(role[key]);
        // }
        log(role);
        log(url);
        function fn(){
            var k = 10;
            return function(){
                k++;
                console.log(k);
            }
        }
        function gn(){
            var k=10;
            return k;
        }
        var t = fn();
        t();
        var t1 = fn();
        t1();
    </script>
</body>

</html>